package com.mzp.XbShop.service;

import com.mzp.XbShop.mapper.UserFavorGoodsDao;
import com.mzp.XbShop.pojo.Goods;
import com.mzp.XbShop.pojo.UserFavorGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description user_favor_goods 服务层
 * @author admin
 * @date 2021-04-19 22:50:00
*/
@Service
public class UserFavorGoodsService {
    @Autowired
    private UserFavorGoodsDao userFavorGoodsDao;
    public List<Map<String,Object>> findByUserIdFavorGoods(String userId) {
        return userFavorGoodsDao.findByUserIdFavorGoods(userId);
    }

    public Integer insert(UserFavorGoods userFavorGoods) {
        return userFavorGoodsDao.insert(userFavorGoods);
    }


    public UserFavorGoods findByGoodsid(String goodsid,String userid) {
        return userFavorGoodsDao.findByGoodsid(goodsid,userid);
    }

    public void deleteFavor(String goodsid, String userid) {
         userFavorGoodsDao.deleteFavor(goodsid,userid);
    }

    public Integer addFavor(String goodsid, String userid) {
        UserFavorGoods userFavorGoods = new UserFavorGoods();
        userFavorGoods.setGoodsid(goodsid);
        userFavorGoods.setUserid(userid);
        userFavorGoods.setIsdel("0");
        userFavorGoods.setIslike(true);
        return userFavorGoodsDao.insert(userFavorGoods);
    }
}
